package com.chenchao.net;

import java.net.InetSocketAddress;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/24 14:40
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.net.Test02.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * InetSocketAddress IP+端口套接地址
 */
public class Test02 {
    public static void main(String[] args) {

        InetSocketAddress inetSocketAddress = new InetSocketAddress("127.0.0.1",8080);
        InetSocketAddress inetSocketAddress2 = new InetSocketAddress("localhost",8080);
        System.out.println(inetSocketAddress);
        /*/127.0.0.1:8080*/
        System.out.println(inetSocketAddress2);
        /*localhost/127.0.0.1:8080*/

        System.out.println(inetSocketAddress2.getAddress());
        /*获取主机地址localhost/127.0.0.1*/
        System.out.println(inetSocketAddress2.getHostName());
        /*获取主机名 localhost*/
        System.out.println(inetSocketAddress2.getPort());
        /*获取端口8080*/


    }
}
